package com.ht.modules.system.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 权限拦截器
 *
 * @author gaozhihua
 */
@Configuration
public class RoleConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new RoleInterceptor());
        //所有路径都被拦截
        registration.addPathPatterns("/**");
        //添加不拦截路径
        registration.excludePathPatterns(
                //登录
                "/**/error",
                //html静态资源
                "/**/*.html",
                //js静态资源
                "/**/*.js",
                //css静态资源
                "/**/*.css",
                "/**/*.woff",
                "/**/*.ttf",
                //登录接口排除
                "/sys/login",
                //登录验证码
                "/auth/2step-code",
                //图片预览不限制token
                "/sys/common/view/**",
                //文件下载不限制token
                "/sys/common/download/**",
                //pdf预览
                "/sys/common/pdf/**",
                //pdf预览需要文件
                "/generic/**",
                "/",
                "/doc.html",
                "/**/*.js",
                "/**/*.css",
                "/**/*.html",
                "/**/*.svg",
                "/**/*.jpg",
                "/**/*.png",
                "/**/*.ico",
                "/druid/**",
                "/swagger-ui.html",
                "/swagger**/**",
                "/webjars/**",
                "/v2/**",
                "/**/*.doc",
                "/**/*.xlsx",
                "/**/*.xls",
                "/**/*.txt",
                //修改密码接口排除
                "/sys/user/updatePassword",
                "/**/*.txt",
                "/**/*.pdf",
                "/**/*.doc",
                "/**/*.docx",
                "/**/*.xls",
                "/**/*.xlsx",
                //cas验证登录
                "/cas/client/validateLogin",
                "/phd/**",
                "/decision/**",
                //注册用户相关
                "/user/tempUser/convertToPinYin",
                "/user/tempUser/add",
                "/user/tempUser/checkUserName",
                //性能监控
                "/actuator/metrics/**",
                "/actuator/httptrace/**",
                "/actuator/redis/**",
                "/WebReport/**",
                //表单设计器
                //自定义表单
                "/desform/**",
                //流程模块组件请求
                "/act/process/**",
                "/act/task/**",
                "/act/model/**",
                "/service/editor/**",
                "/service/model/**",
                "/service/model/**/save",
                "/editor-app/**",
                "/diagram-viewer/**",
                "/modeler.html",
                "/designer",
                "/designer/**",
                "/plug-in/**",
                "/process/extActProcess/startMutilProcess",
                //排除Online请求
                "/auto/cgform/**",
                // 生成apk二维码
                "/apk/sysApk/generateQrCode",
                // 查询最新版本的apk
                "/apk/sysApk/queryNewVersion",
                "/sys/verifyToken",
                "/cas/api/**"
        );
    }

}
